package com.github.tyc.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * 测试定时任务
 */
@Component("testTask")
public class TestTask implements ITask {
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	public void run(String ...params){
		String p = Arrays.stream(params).collect(Collectors.joining(","));
		logger.info("TestTask定时任务正在执行，参数为：{}", p);
		try {
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			throw new RuntimeException("定时任务执行异常");
		}
	}
}
